<?php
	#-------------------------------------------------------------#
	# This file is part of the Kumomado - Virtual Window Platform #
	# for PHP. (c) 2009 Tsai, Min Che <tirme0812@gmail.com>       #
	# Please visit http://www.kumomado.org/ for more information. #
	#                                                             #
	# This software is licensed under the GNU License v3. Please  #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#

	/**
	 * @package libraries/config/
	 * @author Tsai, Min Che
	 * @version 1.0
	 */
	class KumomadoConfig {
		public $config;
		/**
		 * Construct
		 */
		public function __construct($name = null) {
			if (!defined('KUMOMADO_CONFIG_PATH')) {
				throw new KumomadoConfigException('KUMOMADO_CONFIG_PATH not define.');
			}
			if (isset($name)) {
				return $this->load($name);
			}
		}
		/**
		 *
		 * @param string $name
		 * @return array
		 */
		public function load($name) {
			$config_file = KUMOMADO_CONFIG_PATH.$name.'.config.php';
			if (file_exists($config_file)) {
				$this->config = include $config_file;
			} else {
				throw new KumomadoConfigException('Config file can not loaded');
			}
			return $this;
		}
		public function get($name = null) {
			if (isset($this->config[$name])) {
				return $this->config[$name];
			} else {
				return $this->config;
			}
		}
		public function __get($name) {
			return $this->get($name);
		}
	}
?>